package com.hins.demo.dao;

import com.hins.demo.dao.dataobject.AccountDO;
import org.apache.ibatis.annotations.*;

/**
 * Description: 账户表
 *
 * @author wenjiaqi
 * @date 2021/5/14 19:19
 */
@Mapper
public interface AccountMapper {

    @Select("SELECT * FROM account WHERE account_id=#{0}")
    AccountDO selectById(Integer accountId);

    @Select("SELECT * FROM account WHERE account_number=#{0}")
    AccountDO selectByAccountNumber(String accountNumber);

    @Select("SELECT * FROM account WHERE user_id=#{0}")
    AccountDO selectByUserId(Integer userId);

    @Options(useGeneratedKeys = true, keyProperty = "miniClassCourseId")
    @Insert("INSERT INTO account (account_number, user_id, available, daily_limit, currency) " +
            "VALUES " +
            "(#{accountNumber}, #{userId}, #{available}, #{dailyLimit}, #{currency})")
    int insert(AccountDO accountDO);

    @Update("UPDATE account SET account_number=#{accountNumber}, " +
            "user_id=#{userId}, available=#{available}, " +
            "daily_limit=#{dailyLimit}, currency=#{currency}" +
            "WHERE account_id=#{accountId}")
    int update(AccountDO accountDO);

}
